<?php
// 数据库配置 - 请根据实际情况修改
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "jd";

// 创建数据库连接
$conn = new mysqli($servername, $username, $password, $dbname);

// 检查连接
if ($conn->connect_error) {
    die("数据库连接失败: " . $conn->connect_error);
}

// 创建用户表（如果不存在）
function createUserTable($conn) {
    $sql = "CREATE TABLE IF NOT EXISTS users (
        id INT AUTO_INCREMENT PRIMARY KEY,
        username VARCHAR(50) NOT NULL UNIQUE,
        password VARCHAR(255) NOT NULL,
        register_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    )";
    
    if ($conn->query($sql) === FALSE) {
        die("创建表失败: " . $conn->error);
    }
}

// 初始化表结构
createUserTable($conn);
?>